﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YTCMS.Data.Infrastructure
{
    public class SQLPage<T> : IList<T>, IPagedResult<T>
    {

        public int PageIndex
        {
            get { throw new NotImplementedException(); }
        }

        public int PageSize
        {
            get { throw new NotImplementedException(); }
        }

        public int TotalCount
        {
            get { throw new NotImplementedException(); }
        }

        public int TotalPages
        {
            get { throw new NotImplementedException(); }
        }

        public bool HasPreviousPage
        {
            get { throw new NotImplementedException(); }
        }

        public bool HasNextPage
        {
            get { throw new NotImplementedException(); }
        }

        public string Parameters
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public int IndexOf(T item)
        {
            throw new NotImplementedException();
        }

        public void Insert(int index, T item)
        {
            throw new NotImplementedException();
        }

        public void RemoveAt(int index)
        {
            throw new NotImplementedException();
        }

        public T this[int index]
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public void Add(T item)
        {
            throw new NotImplementedException();
        }

        public void Clear()
        {
            throw new NotImplementedException();
        }

        public bool Contains(T item)
        {
            throw new NotImplementedException();
        }

        public void CopyTo(T[] array, int arrayIndex)
        {
            throw new NotImplementedException();
        }

        public int Count
        {
            get { throw new NotImplementedException(); }
        }

        public bool IsReadOnly
        {
            get { throw new NotImplementedException(); }
        }

        public bool Remove(T item)
        {
            throw new NotImplementedException();
        }

        public IEnumerator<T> GetEnumerator()
        {
            throw new NotImplementedException();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            throw new NotImplementedException();
        }
        private readonly IDatabaseFactory databaseFactory;
        private YTContext dataContext;
        public SQLPage(IDatabaseFactory databaseFactory)
        {
            this.databaseFactory = databaseFactory;
        }
        protected YTContext DataContext
        {
            get { return dataContext ?? (dataContext = databaseFactory.Get()); }
        }
        public SQLPage(string sql, int pageIndex, int pageSize)
        {
            var args = new DbParameter[] { 
                    new SqlParameter("pageIndex",pageIndex),
                    new SqlParameter("pageSize",pageSize)                            
                                   };
            IEnumerable query = dataContext.Database.SqlQuery(typeof(T), sql, args);

        }
    }
}
